import { __private, _decorator } from 'cc';
import { SkeletonIdleState } from './SkeletonIdleState';
import { SkeletonMoveState } from './SkeletonMoveState';
import { SkeletonBattleState } from './SkeletonBattleState';
import { SkeletonAttackState } from './SkeletonAttackState';
import { SkeletonStunnedState } from './SkeletonStunnedState';
import { Enemy } from '../Enemy';
import { StateDefine } from '../../Config';

const { ccclass, property } = _decorator;

@ccclass('Enemy_Skeleton')
export class Enemy_Skeleton extends Enemy {
    @property IdleTime: number = 2;
    @property BattleTime: number = 3;

    @property AttackDistance: number = 5;
    @property AttackCoolDown: number = 10;
    LastAttack:number = 0;
    start() {
        super.start();
        this.stateMgr.registState(new SkeletonIdleState(StateDefine.SkeletonIdle,this,StateDefine.SkeletonIdle));
        this.stateMgr.registState(new SkeletonMoveState(StateDefine.SkeletonWalk,this,StateDefine.SkeletonWalk));
        this.stateMgr.registState(new SkeletonBattleState(StateDefine.SkeletonBattle,this,StateDefine.SkeletonWalk));
        this.stateMgr.registState(new SkeletonAttackState(StateDefine.SkeletonAttack,this,StateDefine.SkeletonAttack));
        this.stateMgr.registState(new SkeletonStunnedState(StateDefine.SkeletonStunned,this,StateDefine.SkeletonStunned))
        this.stateMgr.startWith(StateDefine.SkeletonIdle);
    }

    update(deltaTime: number) {
        super.update(deltaTime);
    }
    public CanBeStunned(): boolean {
        if(super.CanBeStunned()){
            this.stateMgr.transit(StateDefine.SkeletonStunned)
            return true;
        }
        return false;
    }
    async HitKnockBack(){
        super.HitKnockBack();
        this.stateMgr.transit(StateDefine.SkeletonBattle)
    }
}


